app.controller("projectInfo", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'project';
	scrollTo(0, 0);
	BackTop()
	$rootScope.record()
	$rootScope.page.goshow = true
	var mySwiper = new Swiper('.banner', {
		autoplay: 2000,
		//		loop:true,
		//		loopAdditionalSlides : 1,
		pagination: '.swiper-pagination',
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		//pagination : '#swiper-pagination1',
		autoplayDisableOnInteraction: false,
	})
	$scope.Timer = function() {
		$(".choose_ul").find(".iconfont").eq(2).css({
			"color": "red"
		})
		$(".time_list").find("i").eq(2).show()
	}
	$(".shadow").css({
		"display": "none"
	})
	var id = $stateParams.Id
		//		http://demo.tl178.cn/House/house_detail
	$scope.tocomment = function(){
		if(!localStorage.getItem("user_ID")&&!localStorage.getItem("token")){
			$(".addressdialog").show();
			$(".addressdialog").html("请先登录才能去评论");
			$(".addressdialog").fadeOut(1200);
		}else{
			$state.go("main.projectcomment",{
				id:id 
			})
		}	
	}
	//查询轮播图
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'House/house_lunimg',
			data: {
				Id: id,
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			},
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
		}).success(function(data) {
			$scope.banner = data["list"]
		})
	//查询楼盘评论
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/house_evaluate',
		data: {
			Id: id,
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		},
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		console.log(data)
		$scope.housecomment = data["list"]
		$scope.house = data["house"]
		var starNum = data["house"]["zh"]
		$scope.num = data["house"]["evaluate_count"]
		setTimeout(function() {
			$rootScope.star(starNum * 2)
		}, 100)
		$scope.tocommentlist = function(){
			$state.go("main.projectcommentlist",{
				id:id
			})
		}
	})
	//查询主要信息
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'House/house_detail',
			data: {
				Id: id,
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			},
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
		}).success(function(data) {
			$rootScope.page.goshow = false
			console.log(data)
			$scope.data = data["list"]
			$scope.houseImg = data["list"]["house_img"]
			var starNum = data["list"]["zh"]
			$scope.collection = data["list"]["member_favorite"]
			var title = data["list"]["name"]
		var desc = data["list"]["describes"]
		var imgUrl = data["list"]["images"]
		//微信分享
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Share/share_s',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data:{
				url:window.location.href
			}
			}).success(function(result) {
					console.log(result)
					var appid = result.appId;
					var timestamp = result.timestamp;
					var nonceStr = result.nonceStr;
					var signature = result.signature;
					if(localStorage.getItem("user_ID")){
						var urlAfter = window.location.href+"?fff="+localStorage.getItem("user_ID")+""; 
					}else{
						var urlAfter = window.location.href
					}	
					wx.config({
						debug: false, //开启调试模式,调用的所有api的返回值会在客户端alert出来
						appId: appid, // 必填，公众号的唯一标识
						timestamp: timestamp, // 必填，生成签名的时间戳
						nonceStr: nonceStr, // 必填，生成签名的随机串
						signature: signature, // 必填，签名
						jsApiList: [
							'onMenuShareTimeline', //分享到朋友圈
							'onMenuShareAppMessage', //分享给朋友
							'onMenuShareQQ', //分享给QQ好友
							'showOptionMenu'
						]
					});

					wx.ready(function() {
						wx.showOptionMenu();
						wx.onMenuShareTimeline({
							title: title,
							desc: desc, // 分享标题							
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图片
							success: function() {
								$rootScope.shareSuccess(2)
								// 用户确认分享后执行的回调函数
							},
							cancel: function() {
								// 用户取消分享后执行的回调函数
							}
						});

						wx.onMenuShareAppMessage({
							title: title, // 分享标题
							desc: desc, // 分享描述
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图片
							type: '', // 分享类型,music、video或link，不填默认为link
							dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
							success: function() {
								$rootScope.shareSuccess(1)
								// 用户确认分享后执行的回调函数
							},
							cancel: function() {
								// 用户取消分享后执行的回调函数
							}
						});

						wx.onMenuShareQQ({
							title: title, // 分享标题
							desc: desc, // 分享描述
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图标
							success: function(res) {
								$rootScope.shareSuccess(3)
								// 用户确认分享后执行的回调函数
							},
							cancel: function(res) {
								// 用户取消分享后执行的回调函数
							}
						});
					});
					wx.error(function(res) {
						console.log(res)
					});
			})
			$scope.torouteinfo = function(){
				$state.go("main.routeInfo",{
					Id:data["list"]["guanlian_house"]
				})
			}
			$scope.tocollection = function() {
				$http({
					method: 'post',
					url: '' + $rootScope.Location + 'Member/click_collect',
					data: {
						id: id,
						user_Id: localStorage.getItem("user_ID"),
						token: localStorage.getItem("token"),
						type: 2
					},
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
				}).success(function(data) {
					if(data["status"] == 0) {
						$(".addressdialog").show();
						$(".addressdialog").html("请先登录才能收藏");
						$(".addressdialog").fadeOut(1200);
					} else {
						$scope.collection = !$scope.collection
						$(".addressdialog").show();
						$(".addressdialog").html(data["message"]);
						$(".addressdialog").fadeOut(1200);
					}

				})
			}
			$(".content").append(data["content"])
			$(".click_more").click(function() {
				$(".click_img").addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
				$(".content").slideDown();
				$(this).parent().hide()
			})
			$(".click_img").click(function() {
					if(!$(this).hasClass("icon-jiantouxia")) {
						$(this).addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
						$(".more").hide()
						$(".content").slideDown();
					} else {
						$(this).removeClass("icon-jiantouxia").addClass("icon-combinedshapefuben")
						$(".content").slideUp()
						$(".more").show()
					}
				})
				//n表示后台获取的星数           
			setTimeout(function() {
				$rootScope.star(starNum * 2)
			}, 100)

		})
		//	 $rootScope.share()

	setTimeout(function() {
		var icon = document.querySelectorAll(".star")
		for(var i = 0; i < icon.length; i++) {
			var a = icon[i].getAttribute("data-info")
			for(var j = 0; j < a; j++) {
				icon[i].querySelectorAll(".xing")[j].className = "on xing"
			}
		}
	}, 100)
	$scope.choose_house2 = function() { //选房按钮点击
		clearInterval($rootScope.waitTime)
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Submit/click_house',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID")
			}
		}).success(function(data) {
			console.log(data)
			$scope.house = data["list"]["house"]
			if(data["list"]["attestation"] == 1) { //注册用户
				$(".shadow2").show()
				setTimeout(function() {
					for(var k = 0; k < $(".layout2 ul li").length; k++) {
						$(".layout2 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout2 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn2").click(function() {
					for(var j = 0; j < $(".layout2 ul li").length; j++) {
						if($(".layout2 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout2 ul li").eq(j).html()
							var house_ID = $(".layout2 ul li").eq(j).attr("data-info")
						}
					}
					$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Submit/sub_house',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							type: 1,
							house_Id: house_ID
						}
					}).success(function(data) {
						if(data["status"] == 1) {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
							setTimeout(function() {
								window.location.reload()
							}, 1000)
						} else {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
						}
					})
				})
			} else { //非注册用户
				setTimeout(function() {
					for(var k = 0; k < $(".layout1 ul li").length; k++) {
						$(".layout1 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout1 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn").click(function() {
					if(!$('.tel').val()) {
						$(".addressdialog").show();
						$(".addressdialog").html("手机号不能为空");
						$(".addressdialog").fadeOut(1200);
					} else {
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test($('.tel').val()) || $('.tel').val().length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
						} else {
							$http({
								method: 'post',
								url: '' + $rootScope.Location + 'Login/send',
								data: {
									mobile: $('.tel').val(),
									type: 3
								},
								headers: {
									'Content-Type': 'application/x-www-form-urlencoded'
								},
							}).success(function(data) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码发送成功");
								$(".addressdialog").fadeOut(1200);
								var wait = 60;
								$(".btn").attr("disabled", true);
								$(".btn").css({
									"color": "#B3B3B3"
								})
								$rootScope.waitTime = setInterval(function() {
									$(".btn").html("重新发送" + "(" + wait + ")")
									wait--
									if(wait < 0) {
										$(".btn").html("获取验证码")
										$(".btn").attr("disabled", false);
										$(".btn").css({
											"color": "#000"
										})
										clearInterval($rootScope.waitTime)
									}
								}, 1000)
							})
						}
					}
				})

				$(".btn1").click(function() {
					var name = $(".name").val();
					for(var j = 0; j < $(".layout1 ul li").length; j++) {
						if($(".layout1 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout1 ul li").eq(j).html()
							var house_Id = $(".layout1 ul li").eq(j).attr("data-info")
						}
					}
					if(name == "") {
						$(".addressdialog").show();
						$(".addressdialog").html("姓名不能为空");
						$(".addressdialog").fadeOut(1200);
						return false
					} else {
						var phone = $('.tel').val();
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test(phone) || phone.length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
							return false;
						} else {
							if(!$(".code").val()) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码不能为空");
								$(".addressdialog").fadeOut(1200);
							} else {
								if(!house) {
									$(".addressdialog").show();
									$(".addressdialog").html("请选择户型");
									$(".addressdialog").fadeOut(1200);
									return false;
								} else {
									$http({
										method: 'post',
										url: '' + $rootScope.Location + 'Submit/sub_house',
										headers: {
											'Content-Type': 'application/x-www-form-urlencoded'
										},
										data: {
											username: name,
											mobile: phone,
											code: $(".code").val(),
											type: 2,
											house_Id: house_Id
										}
									}).success(function(data) {
										if(data["status"] == 1) {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
											setTimeout(function() {
												window.location.reload()
											}, 1000)
										} else {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
										}
									})
								}
							}

						}
					}

				})
				$(".shadow1").show()
			}
		})
	}
	$scope.choose_cha = function() { //取消选房按钮点击
		$(".shadow1").hide()
		$(".shadow2").hide()
	}
}])

app.controller("Mortgage", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'project';
	$scope.page.one = true
	$scope.page.two = false
	$scope.page.three = false
	$scope.discount = "三成"
	$scope.lv = 3.25
	$scope.lv2 = 4.9
		//	$scope.result = 
	$scope.dis = 3
	$scope.daitime = 20
	$(".del_p").click(function() {
		$(".shadow").hide()
	})
	$(".mortgage").click(function() {
		$(".shadow").show()
		$(".choose_time").show()
		var that = $(this)
		$(".choose_time li").click(function() {
			$(".shadow").hide()
			$(".choose_time").hide()
			$scope.daitime = $(this).index()
			that.find("p").html($(this).html())
		})
	})
	$(".discount").click(function() {
		$(".shadow").show()
		$(".choose_discount").show()
		var that = $(this)
		$(".choose_discount li").click(function() {
			$(".shadow").hide()
			$scope.dis = $(this).index() + 1 * 1
			$scope.result = ($(".num").val() - ($scope.dis * $(".num").val()) / 10)
			$(".choose_discount").hide()
			that.find("p").html($(this).html())
			console.log($scope.result)
		})
	})
	$(".discount1").click(function() {
		$(".shadow").show()
		$(".choose_discount").show()
		var that = $(this)
		$(".choose_discount li").click(function() {
			$(".shadow").hide()
			$scope.dis = $(this).index() + 1 * 1
			console.log($scope.dis)
			console.log($(".num2").val())
			$scope.result = ($(".num2").val() - ($scope.dis * $(".num2").val()) / 10)
			console.log($scope.result)
			$(".choose_discount").hide()
			that.find("p").html($(this).html())
		})
	})
	$(".interest").click(function() {
		$(".shadow").show()
		$(".choose_interest").show()
		var that = $(this)
		$(".choose_interest li").click(function() {
			$(".shadow").hide()
			$(".choose_interest").hide()
			$scope.info = $(this).attr("data-info")
			that.find("p").html(($scope.info * $scope.lv).toFixed(2) + "%")
		})
	})
	$(".interest2").click(function() {
		$(".shadow").show()
		$(".choose_interest").show()
		var that = $(this)
		$(".choose_interest li").click(function() {
			$(".shadow").hide()
			$(".choose_interest").hide()
			$scope.info = $(this).attr("data-info")
			that.find("p").html(($scope.info * $scope.lv2).toFixed(2) + "%")
		})
	})
	$scope.type = 1
	$(".left").click(function() {
		$(this).addClass("active")
		$(".right").removeClass("active")
		$scope.type = 1
	})
	$(".right").click(function() {
		$(this).addClass("active")
		$(".left").removeClass("active")
		$scope.type = 2
	})
	$scope.calculate = function() {
		if($scope.page.two == true) {
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Data/gjj_desame',
				data: {
					user_Id: localStorage.getItem("user_ID"),
					token: localStorage.getItem("token"),
					prices: $(".num2").val() * 10000, //总价
					pay_price: ($(".num2").val() * $scope.dis / 10) * 10000, //首付金额
					dai_price: ($(".num2").val() - ($(".num2").val() * $scope.dis / 10)) * 10000, //贷款金额
					lv: 0.049,
					month: $scope.daitime,
					type: $scope.type
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
			}).success(function(data) {
				console.log(data)
				$scope.all_price = data["prices"] / 10000
				$scope.pay_price = data["pay_price"] / 10000
				$scope.dai_price = data["dai_price"] / 10000
				$scope.month = data["month"]
				$scope.lilv = data["lv"]
			})
		}
		if($scope.page.one == true) {
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Data/gjj_desame',
				data: {
					user_Id: localStorage.getItem("user_ID"),
					token: localStorage.getItem("token"),
					prices: $(".num").val() * 10000, //总价
					pay_price: ($(".num").val() * $scope.dis / 10) * 10000, //首付金额
					dai_price: ($(".num").val() - ($(".num").val() * $scope.dis / 10)) * 10000, //贷款金额
					lv: 0.0325,
					month: $scope.daitime,
					type: $scope.type
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
			}).success(function(data) {
				console.log(data)
				$scope.all_price = data["prices"] / 10000
				$scope.pay_price = data["pay_price"] / 10000
				$scope.dai_price = data["dai_price"] / 10000
				$scope.month = data["month"]
				$scope.lilv = data["lv"]
			})
		}
	}

	$scope.pageone = function() {
		$scope.page.one = true
		$scope.page.two = false
		$scope.page.three = false
	}
	$scope.pagetwo = function() {
		$scope.page.one = false
		$scope.page.two = true
		$scope.page.three = false
	}
	$scope.pagethree = function() {
		$scope.page.one = false
		$scope.page.two = false
		$scope.page.three = true
	}
}])

app.controller("newprojectInfo", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'project';
	scrollTo(0, 0);
	BackTop()
	$rootScope.record()
	$rootScope.page.goshow = true
	$scope.Timer = function() {
		$(".choose_ul").find(".iconfont").eq(2).css({
			"color": "red"
		})
		$(".time_list").find("i").eq(2).show()
	}
	$(".shadow").css({
		"display": "none"
	})
	var mySwiper = new Swiper('.banner2', {
		autoplay: 2000,
		//		loop:true,
		//		loopAdditionalSlides : 1,
		pagination: '.swiper-pagination',
		observer: true, //修改swiper自己或子元素时，自动初始化swiper
		observeParents: true, //修改swiper的父元素时，自动初始化swiper
		//pagination : '#swiper-pagination1',
		autoplayDisableOnInteraction: false,
	})
	var id = $stateParams.Id
		//		http://demo.tl178.cn/House/house_detail
	$scope.tocomment = function(){
		if(!localStorage.getItem("user_ID")&&!localStorage.getItem("token")){
			$(".addressdialog").show();
			$(".addressdialog").html("请先登录才能去评论");
			$(".addressdialog").fadeOut(1200);
		}else{
			$state.go("main.projectcomment",{
				id:id
			})
		}	
	}
	//查询轮播图
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'House/house_lunimg',
			data: {
				Id: id,
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			},
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
		}).success(function(data) {
			$scope.banner = data["list"]
		})
	//查询楼盘五证
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/house_wuimg',
		data: {
			Id: id,
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		},
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		$scope.houses_wuimg = data["list"]
	})
	//查询天气情况
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'House/house_weather',
			data: {
				Id: id,
				user_Id: localStorage.getItem("user_ID"),
				token: localStorage.getItem("token")
			},
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
		}).success(function(data) {
			console.log(data)
			$scope.weather = data["list"] //获取天气
			$scope.one = weathertype(data["list"]["one_fairness"])
			$scope.two = weathertype(data["list"]["two_fairness"])
			$scope.three = weathertype(data["list"]["three_fairness"])
			$scope.four = weathertype(data["list"]["four_fairness"])
			$scope.five = weathertype(data["list"]["five_fairness"])
			function weathertype(type) {
			if(type == "阵雨") {
				return 1
			}
			if(type == "小雨") {
				return 2
			}
			if(type == "多云" || type == "多云转晴") {
				return 3
			}
			if(type == "晴天" || type == "晴") {
				return 4
			}
			if(type == "大雨") {
				return 5
			}
			if(type == "中雨") {
				return 6
			}
			if(type == "暴雨") {
				return 7
			}
			if(type == "小雪") {
				return 8
			}
			if(type == "中雪") {
				return 9
			}
			if(type == "大雪") {
				return 10
			}
			if(type == "暴雪") {
				return 11
			}
			if(type == "阴") {
				return 12
			}
			if(type == "冰雹") {
				return 13
			}
			if(type == "风" || type == "大风") {
				return 14
			}
			if(type == "雷电" || type == "雷阵雨") {
				return 15
			}
			if(type == "霾") {
				return 16
			}
			if(type == "闪电") {
				return 17
			}
			if(type == "雾") {
				return 18
			}
			if(type == "雨夹雪") {
				return 19
			}
		}
		})
	//查询户型图	
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/house_houimg',
		data: {
			Id: id,
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		},
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		console.log(data)
		$scope.houseImg = data["list"]
	})
	//查询楼盘评论
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/house_evaluate',
		data: {
			Id: id,
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		},
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data){
		console.log(data)
		$scope.housecomment = data["list"]
		$scope.house = data["house"]
		$scope.num = data["house"]["evaluate_count"]
		var starNum = data["house"]["zh"]
		setTimeout(function() {
			$rootScope.star(starNum * 2)
		}, 100)
		$scope.tocommentlist = function(){
			$state.go("main.projectcommentlist",{
				id:id
			})
		}
	})
	//查询主要信息
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'House/house_detail',
		data: {
			Id: id,
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token")
		},
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
	}).success(function(data) {
		console.log(data)
		$rootScope.page.goshow = false
		$scope.data = data["list"]
		$scope.collection = data["list"]["member_favorite"]
		var title = data["list"]["name"]
		var desc = data["list"]["describes"]
		var imgUrl = data["list"]["images"]
		//微信分享
	$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Share/share_s',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data:{
				url:window.location.href
			}
			}).success(function(result) {
					console.log(result)
					var appid = result.appId;
					var timestamp = result.timestamp;
					var nonceStr = result.nonceStr;
					var signature = result.signature;
					if(localStorage.getItem("user_ID")){
						var urlAfter = window.location.href+"?fff="+localStorage.getItem("user_ID")+""; 
					}else{
						var urlAfter = window.location.href
					}	
					wx.config({
						debug: false, //开启调试模式,调用的所有api的返回值会在客户端alert出来
						appId: appid, // 必填，公众号的唯一标识
						timestamp: timestamp, // 必填，生成签名的时间戳
						nonceStr: nonceStr, // 必填，生成签名的随机串
						signature: signature, // 必填，签名
						jsApiList: [
							'onMenuShareTimeline', //分享到朋友圈
							'onMenuShareAppMessage', //分享给朋友
							'onMenuShareQQ', //分享给QQ好友
							'showOptionMenu'
						]
					});

					wx.ready(function() {
						wx.showOptionMenu();
						wx.onMenuShareTimeline({
							title: title,
							desc: desc, // 分享标题							
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图片
							success: function() {
								// 用户确认分享后执行的回调函数
								$rootScope.shareSuccess(2)
							},
							cancel: function() {
								// 用户取消分享后执行的回调函数
							}
						});

						wx.onMenuShareAppMessage({
							title: title, // 分享标题
							desc: desc, // 分享描述
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图片
							type: '', // 分享类型,music、video或link，不填默认为link
							dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
							success: function() {
								// 用户确认分享后执行的回调函数
								$rootScope.shareSuccess(1)
							},
							cancel: function() {
								// 用户取消分享后执行的回调函数
							}
						});

						wx.onMenuShareQQ({
							title: title, // 分享标题
							desc: desc, // 分享描述
							link: urlAfter, // 分享链接
							imgUrl: imgUrl, // 分享图标
							success: function(res) {
								// 用户确认分享后执行的回调函数
								$rootScope.shareSuccess(3)
							},
							cancel: function(res) {
								// 用户取消分享后执行的回调函数
							}
						});
					});
					wx.error(function(res) {
						console.log(res)
					});
			})
		
		
		$scope.torouteinfo = function(){
			$state.go("main.routeInfo",{
				Id:data["list"]["guanlian_house"]
			})
		}
		$scope.tocollection = function() {
			$http({
				method: 'post',
				url: '' + $rootScope.Location + 'Member/click_collect',
				data: {
					id: id,
					user_Id: localStorage.getItem("user_ID"),
					token: localStorage.getItem("token"),
					type: 2
				},
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				},
			}).success(function(data) {
				if(data["status"] == 0) {
					$(".addressdialog").show();
					$(".addressdialog").html("请先登录才能收藏");
					$(".addressdialog").fadeOut(1200);
				} else {
					$scope.collection = !$scope.collection
					$(".addressdialog").show();
					$(".addressdialog").html(data["message"]);
					$(".addressdialog").fadeOut(1200);
				}
			})
		}
		
		$(".click_img").click(function() {
				if(!$(this).hasClass("icon-jiantouxia")) {
					$(this).addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
					$(this).parent().parent().find(".content_hide").slideDown()
				} else {
					$(this).removeClass("icon-jiantouxia").addClass("icon-combinedshapefuben")
					$(this).parent().parent().find(".content_hide").slideUp()
				}
			})
			//			$(".content").append(data["content"])
		$(".click_more").click(function() {
			$(".click_img").addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
			$(".content").slideDown();
			$(this).parent().hide()
		})
		$(".more").hide()
		$(".click_img2").click(function() {
			if(!$(this).hasClass("icon-jiantouxia")) {
				$(this).addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
				$(".more").hide()
				$(".p2").slideDown();
			} else {
				$(this).removeClass("icon-jiantouxia").addClass("icon-combinedshapefuben")
				$(".p2").slideUp()
				$(".more").show()
			}
		})
		$(".more").click(function() {
				$(".p2").slideDown();
				$(".click_img2").addClass("icon-jiantouxia").removeClass("icon-combinedshapefuben")
			})
			//n表示后台获取的星数           
		
	})
	$scope.choose_house2 = function() { //选房按钮点击
		clearInterval($rootScope.waitTime)
		$http({
			method: 'post',
			url: '' + $rootScope.Location + 'Submit/click_house',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			data: {
				user_Id: localStorage.getItem("user_ID")
			}
		}).success(function(data) {
			console.log(data)
			$scope.house = data["list"]["house"]
			if(data["list"]["attestation"] == 1) { //注册用户
				$(".shadow2").show()
				setTimeout(function() {
					for(var k = 0; k < $(".layout2 ul li").length; k++) {
						$(".layout2 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout2 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn2").click(function() {
					for(var j = 0; j < $(".layout2 ul li").length; j++) {
						if($(".layout2 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout2 ul li").eq(j).html()
							var house_ID = $(".layout2 ul li").eq(j).attr("data-info")
						}
					}
					$http({
						method: 'post',
						url: '' + $rootScope.Location + 'Submit/sub_house',
						headers: {
							'Content-Type': 'application/x-www-form-urlencoded'
						},
						data: {
							user_Id: localStorage.getItem("user_ID"),
							token: localStorage.getItem("token"),
							type: 1,
							house_Id: house_ID
						}
					}).success(function(data) {
						if(data["status"] == 1) {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
							setTimeout(function() {
								window.location.reload()
							}, 1000)
						} else {
							$(".addressdialog").show();
							$(".addressdialog").html(data["message"]);
							$(".addressdialog").fadeOut(1200);
						}
					})
				})
			} else { //非注册用户
				setTimeout(function() {
					for(var k = 0; k < $(".layout1 ul li").length; k++) {
						$(".layout1 ul li").eq(k).click(function() {
							var index = $(this).index()
							$(".layout1 ul li").eq(index).attr("class", "active").siblings().removeClass("active")
						})
					}
				}, 100)
				$(".btn").click(function() {
					if(!$('.tel').val()) {
						$(".addressdialog").show();
						$(".addressdialog").html("手机号不能为空");
						$(".addressdialog").fadeOut(1200);
					} else {
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test($('.tel').val()) || $('.tel').val().length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
						} else {
							$http({
								method: 'post',
								url: '' + $rootScope.Location + 'Login/send',
								data: {
									mobile: $('.tel').val(),
									type: 3
								},
								headers: {
									'Content-Type': 'application/x-www-form-urlencoded'
								},
							}).success(function(data) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码发送成功");
								$(".addressdialog").fadeOut(1200);
								var wait = 60;
								$(".btn").attr("disabled", true);
								$(".btn").css({
									"color": "#B3B3B3"
								})
								$rootScope.waitTime = setInterval(function() {
									$(".btn").html("重新发送" + "(" + wait + ")")
									wait--
									if(wait < 0) {
										$(".btn").html("获取验证码")
										$(".btn").attr("disabled", false);
										$(".btn").css({
											"color": "#000"
										})
										clearInterval($rootScope.waitTime)
									}
								}, 1000)
							})
						}
					}
				})

				$(".btn1").click(function() {
					var name = $(".name").val();
					for(var j = 0; j < $(".layout1 ul li").length; j++) {
						if($(".layout1 ul li").eq(j).attr("class") == "active") {
							var house = $(".layout1 ul li").eq(j).html()
							var house_Id = $(".layout1 ul li").eq(j).attr("data-info")
						}
					}
					if(name == "") {
						$(".addressdialog").show();
						$(".addressdialog").html("姓名不能为空");
						$(".addressdialog").fadeOut(1200);
						return false
					} else {
						var phone = $('.tel').val();
						var reg = new RegExp(/^1[34578]\d{9}$/);
						if(!reg.test(phone) || phone.length != 11) {
							$(".addressdialog").show();
							$(".addressdialog").html("请输入正确的手机号");
							$(".addressdialog").fadeOut(1200);
							return false;
						} else {
							if(!$(".code").val()) {
								$(".addressdialog").show();
								$(".addressdialog").html("验证码不能为空");
								$(".addressdialog").fadeOut(1200);
							} else {
								if(!house) {
									$(".addressdialog").show();
									$(".addressdialog").html("请选择户型");
									$(".addressdialog").fadeOut(1200);
									return false;
								} else {
									$http({
										method: 'post',
										url: '' + $rootScope.Location + 'Submit/sub_house',
										headers: {
											'Content-Type': 'application/x-www-form-urlencoded'
										},
										data: {
											username: name,
											mobile: phone,
											code: $(".code").val(),
											type: 2,
											house_Id: house_Id
										}
									}).success(function(data) {
										if(data["status"] == 1) {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
											setTimeout(function() {
												window.location.reload()
											}, 1000)
										} else {
											$(".addressdialog").show();
											$(".addressdialog").html(data["message"]);
											$(".addressdialog").fadeOut(1200);
										}
									})
								}
							}

						}
					}

				})
				$(".shadow1").show()
			}
		})
	}
	$scope.choose_cha = function() { //取消选房按钮点击
		$(".shadow1").hide()
		$(".shadow2").hide()
	}
}])

app.controller("projectcomment", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'project';
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Comment/go_houses',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
			houses_Id:$stateParams.id
		}
	}).success(function(data) {
		$scope.img = data["list"]["img"]
		$scope.name = data["list"]["name"]
	})
	//星级评分
	for(var i=0;i<$(".star").length;i++){
		$(".star").eq(i).find("ul li").click(function(){
			var index = $(this).index()
			var Index = $(this).parent().find("li").length
			$(this).parent().attr("data-info",index+1)
			for(var j=0;j<Index;j++){
				$(this).parent().find("li")[j].className = j < index+1? "on" : ""
			}
		})
	}
	$(".login_btn").click(function(){
		var price = $(".star").eq(0).find("ul").attr("data-info")
		var district = $(".star").eq(1).find("ul").attr("data-info")
		var traffic = $(".star").eq(2).find("ul").attr("data-info")
		var mating = $(".star").eq(3).find("ul").attr("data-info")
		var environment = $(".star").eq(4).find("ul").attr("data-info")
		$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Comment/comment_houses',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
			houses_Id:$stateParams.id,
			content:$("#textareabox").val(),
			price:price,
			district:district,
			traffic:traffic,
			mating:mating,
			environment:environment,
		}
		}).success(function(data) {
			console.log(data)
			if(data["status"]==1){
				$(".addressdialog").show();
				$(".addressdialog").html(data["message"]);
				$(".addressdialog").fadeOut(1200);
				setTimeout(function(){
					$state.go("main.projectcommentlist",{
						id:$stateParams.id
					})
				},1000)	
			}else{
				$(".addressdialog").show();
				$(".addressdialog").html(data["message"]);
				$(".addressdialog").fadeOut(1200);
			}		
		})
	})
	
}])

app.controller("projectcommentlist", ["$scope", "$stateParams", "$rootScope", "$state", "$http", function($scope, $stateParams, $rootScope, $state, $http) {
	$rootScope.page.showfooter = true;
	$rootScope.page.footer = 'project';
	$http({
		method: 'post',
		url: '' + $rootScope.Location + 'Comment/h_comment_list',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		data: {
			user_Id: localStorage.getItem("user_ID"),
			token: localStorage.getItem("token"),
			houses_Id:$stateParams.id
		}
		}).success(function(data) {
			console.log(data)
			$scope.list = data["list"]
		})
}])